<?php

/**
 * Recurso form base class.
 *
 * @package    proyectoMOD2
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormGeneratedTemplate.php 12815 2008-11-09 10:43:58Z fabien $
 */
class BaseRecursoForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'cedula'           => new sfWidgetFormInput(),
      'login'            => new sfWidgetFormInputHidden(),
      'password'         => new sfWidgetFormInputHidden(),
      'primer_nombre'    => new sfWidgetFormInput(),
      'segundo_nombre'   => new sfWidgetFormInput(),
      'primer_apellido'  => new sfWidgetFormInput(),
      'segundo_apellido' => new sfWidgetFormInput(),
      'fecha_nac'        => new sfWidgetFormDate(),
      'edo_civil'        => new sfWidgetFormPropelSelect(array('model' => 'Edocivil', 'add_empty' => false)),
      'sexo'             => new sfWidgetFormPropelSelect(array('model' => 'Sexo', 'add_empty' => false)),
      'telf_domicilio'   => new sfWidgetFormInput(),
      'telf_celular'     => new sfWidgetFormInput(),
      'direccion'        => new sfWidgetFormTextarea(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorPropelChoice(array('model' => 'Recurso', 'column' => 'id', 'required' => false)),
      'cedula'           => new sfValidatorInteger(),
      'login'            => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'password'         => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'primer_nombre'    => new sfValidatorString(array('max_length' => 40)),
      'segundo_nombre'   => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'primer_apellido'  => new sfValidatorString(array('max_length' => 40)),
      'segundo_apellido' => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'fecha_nac'        => new sfValidatorDate(),
      'edo_civil'        => new sfValidatorString(array('max_length' => 40)),
      'sexo'             => new sfValidatorString(array('max_length' => 40)),
      'telf_domicilio'   => new sfValidatorRegex(array('pattern' => '/^(\(\d{4}\)[- ]?|\d{3}[- ])?\d{3}[- ]\d{4}$/'), 
	  array('invalid' => 'numero de telefono invalido')),
      'telf_celular'     => new sfValidatorRegex(array('pattern' => '/^(\(\d{4}\)[- ]?|\d{3}[- ])?\d{3}[- ]\d{4}$/'), 
	  array('invalid' => 'numero de telefono celular invalido')),
      'direccion'        => new sfValidatorString(array('max_length' => 40)),
    ));
	//acepta expresiones Matches  	
	//(555)555-5555 | (555) 555-5555 | 555-5555
	//Non-Matches 	
	//5555555555 | 555.555.5555 | (555 555-5555

    $this->validatorSchema->setPostValidator(
      new sfValidatorPropelUnique(array('model' => 'Recurso', 'column' => array('cedula')))
    );

    $this->widgetSchema->setNameFormat('recurso[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Recurso';
  }


}
